home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995…tember: Reference Library / Dev.CD Sep 95 RL / Dev.CD Sep 95 RL.toast / mac / Technical Documentation / develop / develop Issue 21 code / Hierarchical Lists / main.cp < prev    next >
Encoding:
Text File  |  1994-08-27  |  3.4 KB  |  137 lines  |  [TEXT/MMCC]

  1. //---------------------------------------------------------------------------------------
  2. //
  3. //    List Tester: Main
  4. //
  5. //---------------------------------------------------------------------------------------
  6.  
  7. #include <string.h>
  8. #include <LApplication.h>
  9. #include <LWindow.h>
  10. #include <LGrowZone.h>
  11. #include <UScreenPort.h>
  12. #include <PPobClasses.h>
  13. #include <URegistrar.h>
  14. #include <UMemoryMgr.h>
  15. #include <UPowerTools.h>
  16. #include <PP_Messages.h>
  17. #include "resources.h"
  18. #include "CMyCustomListBox.h"
  19. #include "CMyHierListBox.h"
  20. #include "CMyDiskListBox.h"
  21.  
  22. //---------------------------------------------------------------------------------------
  23.  
  24. class    CListApp : public LApplication {
  25. public:
  26.             CListApp(void);
  27.     virtual ~CListApp(void);
  28.     
  29.     virtual Boolean        ObeyCommand(CommandT inCommand, void* ioParam);
  30.     virtual void        FindCommandStatus(CommandT inCommand,
  31.                             Boolean &outEnabled, Boolean &outUsesMark,
  32.                             Char16 &outMark, Str255 outName);
  33.  
  34. protected:
  35.     virtual void        StartUp();
  36.  
  37. };
  38.  
  39. //---------------------------------------------------------------------------------------
  40.  
  41. CListApp::CListApp(void)
  42. {
  43.   UScreenPort::Initialize();
  44.   
  45. // 'RegisterAllPPClasses' registers all standard PowerPlant classes.  Because many of them
  46. // are not needed by this application, it would add about 50K of unused code.  Registering
  47. // the two classes we need, helps the linker removing redundant code.
  48. //  RegisterAllPPClasses();
  49.  
  50.     URegistrar::RegisterClass('lbox', (ClassCreatorFunc) LListBox::CreateListBoxStream);
  51.     URegistrar::RegisterClass('wind', (ClassCreatorFunc) LWindow::CreateWindowStream);
  52.  
  53.   URegistrar::RegisterClass (CMyCustomListBox::classID,    (ClassCreatorFunc) CMyCustomListBox::CreateFromStream);
  54.   URegistrar::RegisterClass (CMyHierListBox::classID,    (ClassCreatorFunc) CMyHierListBox::CreateFromStream);
  55.   URegistrar::RegisterClass (CMyDiskListBox::classID,    (ClassCreatorFunc) CMyDiskListBox::CreateFromStream);
  56. }
  57.  
  58. CListApp::~CListApp()
  59. {
  60. }
  61.  
  62. void CListApp::StartUp()
  63. {
  64.   ObeyCommand(cmd_New, nil);
  65. }
  66.  
  67. //---------------------------------------------------------------------------------------
  68.  
  69. Boolean CListApp::ObeyCommand(CommandT inCommand, void *ioParam)
  70. { Boolean        cmdHandled = true;
  71.     
  72.   switch (inCommand) {
  73.     
  74.     case cmd_EasyList:
  75.         LWindow::CreateWindow (EasyList_PPob, this);
  76.         break ;
  77.         
  78.     case cmd_CustomList:
  79.         LWindow::CreateWindow (CustomList_PPob, this);
  80.         break;
  81.         
  82.     case cmd_HierList:
  83.         LWindow::CreateWindow (HierList_PPob, this);
  84.         break ;
  85.             
  86.     case cmd_DiskList:
  87.         LWindow::CreateWindow (DiskList_PPob, this);
  88.         break ;
  89.             
  90.     default:
  91.         cmdHandled = LApplication::ObeyCommand (inCommand, ioParam);
  92.         break;
  93.   }
  94.     
  95.   return cmdHandled;
  96. }
  97.  
  98. //---------------------------------------------------------------------------------------
  99.  
  100. void CListApp::FindCommandStatus(
  101.     CommandT    inCommand,
  102.     Boolean        &outEnabled,
  103.     Boolean        &outUsesMark,
  104.     Char16        &outMark,
  105.     Str255        outName)
  106. {
  107.   switch (inCommand) {
  108.  
  109.     case cmd_EasyList:
  110.     case cmd_CustomList:
  111.     case cmd_HierList:
  112.     case cmd_DiskList:
  113.         outEnabled = true;
  114.         outUsesMark = false;
  115.         break;
  116.  
  117.     default:
  118.         LApplication::FindCommandStatus(inCommand, outEnabled,
  119.                                             outUsesMark, outMark, outName);
  120.         break;
  121.   }
  122. }
  123.  
  124. //---------------------------------------------------------------------------------------
  125.  
  126. void main (void)
  127. {
  128.   InitializeHeap(4);
  129.   InitializeToolbox();
  130.   new LGrowZone(20000);
  131.  
  132.   CListApp    theApp;
  133.   theApp.Run();
  134. }
  135.  
  136. //---------------------------------------------------------------------------------------
  137.